<template>
  <div id="vueapp">
    <!-- <span @click="refesh" class="refesh-btn">测试刷新</span> -->
    <div class="app-audios">
      <audio :src="musicMain" ref="musicMain" id="music-main" controls  loop  autoplay></audio>
    </div>
    <keep-alive>
      <router-view v-if="$route.meta.keepAlive"></router-view>
    </keep-alive>
    <router-view v-if="!$route.meta.keepAlive"></router-view>
  </div>
</template>
<script>
import Utils from './utils.js'
import { Toast } from 'mint-ui'

export default {
  name: "App",
  components: {
    
  },
  data () {
    return {
      musicMain:require('./assets/music.mp3'),
      show:true,
      title:'',
      loadingDivWidth:120,
    };
  },
  computed:{
    toast(){
      return this.$store.state.toastText
    },
    shareOpt(){
      return {
        title: "杭州银行抓年兽标题",
        desc: "抓年兽描述",
        link: window.location.href.split('#')[0] + '#/shareStart?showId=' + this.$store.state.user.openid,
        imgUrl: window.location.href.split('index.html')[0]+'static/logo.jpg',
        success: function () {
          // 用户确认分享后执行的回调函数
          //this.$store.commit('toast', '分享成功')
        },
        cancel: function () {
          // 用户取消分享后执行的回调函数
          //this.$store.commit('toast', '取消分享')
        }
      }
    }
  },
  watch:{
    toast:function(val){
      if(val){
        Toast(val)
        // this.$toast.center(val)
      }
    },
    // '$route':'setSdk'
  },
  mounted(){
      
    let vm = this
    vm.play()
    document.addEventListener('WeixinJSBridgeReady',vm.play,false)
    //vm.$this.$store.commit('updateMusicStatus',true)
    //this.setSdk()
  },
  methods:{
    refesh(){
      localStorage.clear()
      window.location.href='http://temporary.birdjia.com/bird_dsp/activity/monsterNian/dist/index.html'
    },
    setSdk(){
      // let vm = this
      // wxSetConfig = function (data) {
      //   //微信授权页面sdk
      //   wx.config({
      //     debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
      //     appId: Utils.wxConfig.appid, // 必填，公众号的唯一标识
      //     timestamp: data.timestamp, // 必填，生成签名的时间戳
      //     nonceStr: data.nonceStr, // 必填，生成签名的随机串
      //     signature: data.signature,// 必填，签名，见附录1
      //     jsApiList: ['onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
      //   });
      //   wx.ready(function(){
      //     wx.onMenuShareTimeline(vm.shareOpt)
      //     wx.onMenuShareAppMessage(vm.shareOpt)
      //   })
      // }

      // this.$store.dispatch('getWxConfig').then(data=>{
      //   wxSetConfig(data)
      // })
    },
    play(){
      // let audio = document.getElementById('#music-main')
      // audio.src = './assets/music.mp3'
      // audio.load()
      this.$store.commit('updateMusicStatus',true)
    },

    
  },
}
</script>
<style lang="scss" >
 @import './styles/common';
 html,body{
   margin: 0;
   padding: 0;
   width: 100%;
   height: 100%;
 }
 #vueapp {
  background: #fff;
  color: #fff;
  // width: px2rem(200);
  // height: px2rem(200);
  font-size: 16px;
  margin: 0 auto;
  box-sizing: border-box;
  position: relative;
  height: 100%;
  @include media-screen();
  overflow-y: scroll;

}
.refesh-btn{
  position: fixed;
  z-index: 10000000;
  bottom: 0;
  right: 0;
  background-color: #999;
  color: #fff;
}
.app-audios{
  width: 0;
  height: 0;
  overflow: hidden;
}
</style>